/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package upeu.util;

import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;

/**
 *
 * @author Alumno
 */
public class DBConexion {
  public Connection conexion=null;
  public String qry=null;
  public Statement stm=null;
  public ResultSet rs=null;
   
    public DBConexion(){  
    }
   /* public  Connection conectaDB(){
        try {
            if(conexion==null){
            Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
            conexion=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "alumno", "a123456");
         }   
        } catch (Exception e) {
            System.out.println("error en Conexion..."+e.getMessage());
        }
        return conexion;
    }*/
       public  void conectaDBE(){
        try {
            if(conexion==null){
            Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
            conexion=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "alumno", "a123456");
         }   
        } catch (Exception e) {
            System.out.println("error en Conexion..."+e.getMessage());
        }
        return ;
    }
    
    public void cerrarDB(){
        try {
           if(rs!=null){rs.close();}
            if(stm!=null){stm.close();}
           if(conexion!=null){ conexion.close();}
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        
    }
}
